package com.example.hibernate.demo.repository;

import com.example.hibernate.demo.entity.Payment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface PaymentRepository extends JpaRepository<Payment, Long> {
    
    List<Payment> findByStatus(Payment.PaymentStatus status);
    
    List<Payment> findByPaymentDateBetween(LocalDateTime start, LocalDateTime end);
    
    @Query("SELECT p FROM Payment p WHERE p.amount > :amount")
    List<Payment> findByAmountGreaterThan(BigDecimal amount);
    
    @Query("SELECT p FROM CreditCardPayment p")
    List<Payment> findAllCreditCardPayments();
    
    @Query("SELECT p FROM BankTransferPayment p")
    List<Payment> findAllBankTransferPayments();
}